package cobots.swarm.agents;

import java.awt.geom.Point2D;

import cobots.swarm.main.SwarmState;


public class FollowerAgent extends Agent {

	//protected short id = 0;
	protected short leaderId = -1;
	
	
	public short getId() {
		return id;
	}
	public void setId(short id) {
		this.id = id;
	}
	public short getLeaderId() {
		return leaderId;
	}
	public void setLeaderId(int leaderId) {
		this.leaderId = (short)leaderId;
	}

	public FollowerAgent(int id) {
		super(0,0,1,1);  
		// Here since it is superimposing the main method hence we call the super
		this.id = (short)id;
	}
	
	public boolean isFree() {
		return getLeaderId() == -1;
	}
	
	@Override
	public Point2D computeMovement() {
		if (leaderId != -1) {
			LeaderAgent l = SwarmState.leader(leaderId);
			interactCounter++;
			return moveTowards(l);
		}
		else
			return super.computeMovement();		
	}
	
	@Override
	public String toString() {
		return("F["+id+" "+x+" "+y+"] -> "+leaderId);
	}
}
